package artid.com.arttogoa.parser;

import java.io.Serializable;

import org.json.JSONObject;

import android.text.TextUtils;

public class UserItem extends AppItem implements Serializable {
	public static final long serialVersionUID = 1L;
	private String token;// 登录返回字段
	private String uid;
	private String mobile;
	private String avatarurl;
	private String artnumber;
	private String follownumber;
	private String news;
	private String realname;
	private String native_place;
	private String good_at;
	private String university;
	private String is_auth;
	private String memo;
	private String trendsnum;
	private String newsnum;
	private String recordnum;
	private String autograph;
	private String path;
	private String goodsnum;//艺术品出售数量
	private String available_predeposit;//余额
	private String aid;//艺术家类别ID
	private String aname;//艺术家类别名
	
	

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public String getUrl(String url) {
		String pathName = url.substring(url.lastIndexOf("/") + 1, url.length());
		String name = pathName.substring(0, pathName.lastIndexOf("."));
		String com = name.substring(0, name.indexOf("_"));
		return url.substring(0, url.lastIndexOf("/") + 1) + com
				+ pathName.substring(pathName.lastIndexOf("."));
	}

	private boolean isLogin = false;

	@Override
	public void parse(JSONObject obj) {
		if (null == obj) {
			return;
		}
		token = obj.optString("token");
		uid = obj.optString("uid");
		mobile = obj.optString("mobile");
		setAvatarurl(obj.optString("avatarurl"));
		artnumber = obj.optString("artnumber");
		follownumber = obj.optString("follownumber");
		news = obj.optString("news");
		news = obj.optString("news");
		realname = obj.optString("realname");
		native_place = obj.optString("native_place");
		good_at = obj.optString("good_at");
		university = obj.optString("university");
		is_auth = obj.optString("is_auth");
		memo = obj.optString("memo");
		trendsnum = obj.optString("trendsnum");
		newsnum = obj.optString("newsnum");
		recordnum = obj.optString("recordnum");
		autograph = obj.optString("autograph");
		goodsnum = obj.optString("goodsnum");
		available_predeposit = obj.optString("available_predeposit");
		aid = obj.optString("aid");
		aname = obj.optString("aname");

		isLogin = true;
	}

	public void parse(UserItem data) {
		if (data == null) {
			return;
		}
		if (!TextUtils.isEmpty(data.token)) {
			this.token = data.token;
		}
		if (!TextUtils.isEmpty(data.uid)) {
			this.uid = data.uid;
		}
		if (!TextUtils.isEmpty(data.mobile)) {
			this.mobile = data.mobile;
		}
		if (!TextUtils.isEmpty(data.avatarurl)) {
			this.avatarurl = data.avatarurl;
		}
		if (!TextUtils.isEmpty(data.artnumber)) {
			this.artnumber = data.artnumber;
		}
		if (!TextUtils.isEmpty(data.follownumber)) {
			this.follownumber = data.follownumber;
		}
		if (!TextUtils.isEmpty(data.news)) {
			this.news = data.news;
		}
		if (!TextUtils.isEmpty(data.realname)) {
			this.realname = data.realname;
		}
		if (!TextUtils.isEmpty(data.native_place)) {
			this.native_place = data.native_place;
		}
		if (!TextUtils.isEmpty(data.good_at)) {
			this.good_at = data.good_at;
		}
		if (!TextUtils.isEmpty(data.good_at)) {
			this.good_at = data.good_at;
		}
		if (!TextUtils.isEmpty(data.university)) {
			this.university = data.university;
		}
		if (!TextUtils.isEmpty(data.is_auth)) {
			this.is_auth = data.is_auth;
		}
		if (!TextUtils.isEmpty(data.memo)) {
			this.memo = data.memo;
		}
		if (!TextUtils.isEmpty(data.trendsnum)) {
			this.trendsnum = data.trendsnum;
		}
		if (!TextUtils.isEmpty(data.newsnum)) {
			this.newsnum = data.newsnum;
		}
		if (!TextUtils.isEmpty(data.recordnum)) {
			this.recordnum = data.recordnum;
		}
		if (!TextUtils.isEmpty(data.autograph)) {
			this.autograph = data.autograph;
		}
		if (!TextUtils.isEmpty(data.goodsnum)) {
			this.goodsnum = data.goodsnum;
		}
		if (!TextUtils.isEmpty(data.available_predeposit)) {
			this.available_predeposit = data.available_predeposit;
		}
		if (!TextUtils.isEmpty(data.aid)) {
			this.aid = data.aid;
		}
		if (!TextUtils.isEmpty(data.aname)) {
			this.aname = data.aname;
		}
		isLogin = true;

	}

	public String getAutograph() {
		return autograph;
	}

	public void setAutograph(String autograph) {
		this.autograph = autograph;
	}

	public String getUid() {
		return uid;
	}

	public void setUid(String uid) {
		this.uid = uid;
	}

	public String getAvatarurl() {
		return avatarurl;
	}

	public void setAvatarurl(String avatarurl) {
		this.avatarurl = avatarurl;
		if (avatarurl.contains("_")) {
			setPath(getUrl(avatarurl));
		}else{
			setPath(avatarurl);
		}
	}

	public String getArtnumber() {
		return artnumber;
	}

	public void setArtnumber(String artnumber) {
		this.artnumber = artnumber;
	}

	public String getFollownumber() {
		return follownumber;
	}

	public void setFollownumber(String follownumber) {
		this.follownumber = follownumber;
	}

	public String getNews() {
		return news;
	}

	public void setNews(String news) {
		this.news = news;
	}

	public String getNative_place() {
		return native_place;
	}

	public void setNative_place(String native_place) {
		this.native_place = native_place;
	}

	public String getGood_at() {
		return good_at;
	}

	public void setGood_at(String good_at) {
		this.good_at = good_at;
	}

	public String getUniversity() {
		return university;
	}

	public void setUniversity(String university) {
		this.university = university;
	}

	public String getIs_auth() {
		return is_auth;
	}

	public void setIs_auth(String is_auth) {
		this.is_auth = is_auth;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}

	public String getTrendsnum() {
		return trendsnum;
	}

	public void setTrendsnum(String trendsnum) {
		this.trendsnum = trendsnum;
	}

	public String getNewsnum() {
		return newsnum;
	}

	public void setNewsnum(String newsnum) {
		this.newsnum = newsnum;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public boolean isLogin() {
		return isLogin;
	}

	public void setLogin(boolean isLogin) {
		this.isLogin = isLogin;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getRecordnum() {
		return recordnum;
	}

	public void setRecordnum(String recordnum) {
		this.recordnum = recordnum;
	}
	

	public String getGoodsnum() {
		return goodsnum;
	}

	public void setGoodsnum(String goodsnum) {
		this.goodsnum = goodsnum;
	}

	public String getAvailable_predeposit() {
		return available_predeposit;
	}

	public void setAvailable_predeposit(String available_predeposit) {
		this.available_predeposit = available_predeposit;
	}

	public String getAid() {
		return aid;
	}

	public void setAid(String aid) {
		this.aid = aid;
	}

	public String getAname() {
		return aname;
	}

	public void setAname(String aname) {
		this.aname = aname;
	}

	@Override
	public String toString() {
		return "UserItem [token=" + token + ", uid=" + uid + ", mobile="
				+ mobile + ", avatarurl=" + avatarurl + ", artnumber="
				+ artnumber + ", follownumber=" + follownumber + ", news="
				+ news + ", realname=" + realname + ", native_place="
				+ native_place + ", good_at=" + good_at + ", university="
				+ university + ", is_auth=" + is_auth + ", memo=" + memo
				+ ", trendsnum=" + trendsnum + ", newsnum=" + newsnum
				+ ", recordnum=" + recordnum + ", autograph=" + autograph
				+ ", path=" + path + ", goodsnum=" + goodsnum
				+ ", available_predeposit=" + available_predeposit + ", aid="
				+ aid + ", aname=" + aname + ", isLogin=" + isLogin + "]";
	}


}
